import axios from 'axios'

export const commonColumn = [
  {
    prop: 'customerLabelId',
    label: '客户级别',
    search: { el: 'select', props: { placeholder: '请选择客户级别', multiple: true, collapseTags: true } },
    enum: () => {
      return new Promise(reslove => {
        axios.get("/customerLabel").then(res=>{
          const data = res.data.map(item => ({
            label: item.customerLabel,
            value: item.id
          }))
          reslove({ data });
        }).catch(() => {
          resolve({ data: [] });
        })
      })
    }
  },
  {
    prop: 'customerSourceId',
    label: '客户来源',
    search: { el: 'select', props: { placeholder: '请选择客户来源', multiple: true, collapseTags: true } },
    enum: () => {
      return new Promise(reslove => {
        axios.get("/customerSource").then(res=>{
          const data = res.data.map(item => ({
            label: item.customerSource,
            value: item.id
          }))
          reslove({ data });
        }).catch(() => {
          resolve({ data: [] });
        })
      })
    }
  },
  {
    prop: 'customerTypeId',
    label: '客户销售渠道',
    search: { el: 'select', props: { placeholder: '请选择客户销售渠道', multiple: true, collapseTags: true } },
    enum: () => {
      return new Promise(reslove => {
        axios.get("/customerType").then(res=>{
          const data = res.data.map(item => ({
            label: item.customerType,
            value: item.id
          }))
          reslove({ data });
        }).catch(() => {
          resolve({ data: [] });
        })
      })
    }
  },
  {
    prop: 'customerName',
    label: '客户名',
    search: {
      el: 'input',
      props: { placeholder: '请输入客户名' }
    }
  },
  {
    prop: 'phone',
    label: '手机号码',
    search: {
      el: 'input',
      props: { placeholder: '请输入手机号码' }
    }
  },
  {
    prop: 'time',
    label: '成交时间',
    search: {
      el: 'date-picker',
      props: { type: 'daterange', 'value-format': 'yyyy-MM-dd' }
    }
  }
];

export const customerColumn = [
  {
    prop: 'customerLabelId',
    label: '客户级别',
    search: { el: 'select', props: { placeholder: '请选择客户级别', multiple: true, collapseTags: true } },
    enum: () => {
      return new Promise(reslove => {
        axios.get("/customerLabel").then(res=>{
          const data = res.data.map(item => ({
            label: item.customerLabel,
            value: item.id
          }))
          reslove({ data });
        }).catch(() => {
          resolve({ data: [] });
        })
      })
    }
  },
  {
    prop: 'customerSourceId',
    label: '客户来源',
    search: { el: 'select', props: { placeholder: '请选择客户来源', multiple: true, collapseTags: true } },
    enum: () => {
      return new Promise(reslove => {
        axios.get("/customerSource").then(res=>{
          const data = res.data.map(item => ({
            label: item.customerSource,
            value: item.id
          }))
          reslove({ data });
        }).catch(() => {
          resolve({ data: [] });
        })
      })
    }
  },
  {
    prop: 'customerTypeId',
    label: '客户销售渠道',
    search: { el: 'select', props: { placeholder: '请选择客户销售渠道', multiple: true, collapseTags: true } },
    enum: () => {
      return new Promise(reslove => {
        axios.get("/customerType").then(res=>{
          const data = res.data.map(item => ({
            label: item.customerType,
            value: item.id
          }))
          reslove({ data });
        }).catch(() => {
          resolve({ data: [] });
        })
      })
    }
  },
  {
    prop: 'salesmanId',
    label: '归属人',
    search: { el: 'select', props: { placeholder: '请选择归属人' } },
    enum: () => {
      return new Promise(reslove => {
        axios.get("/employee").then(res=>{
          const data = res.data.map(item => ({
            label: item.adminName,
            value: item.id
          }))
          reslove({ data });
        }).catch(() => {
          resolve({ data: [] });
        })
      })
    }
  },
  {
    prop: 'customerName',
    label: '客户名',
    search: {
      el: 'input',
      props: { placeholder: '请输入客户名' }
    }
  },
  {
    prop: 'phone',
    label: '手机号码',
    search: {
      el: 'input',
      props: { placeholder: '请输入手机号码' }
    }
  },
  {
    prop: 'time',
    label: '成交时间',
    search: {
      el: 'date-picker',
      props: { type: 'daterange', 'value-format': 'yyyy-MM-dd' }
    }
  }
]